﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Ex3.ExtractSubstring
{
    class ExtractSubstring
    {
        public static void PrintTargets(string target, string text)
        {
            Regex regex = new Regex(string.Format(@"\w*{0}\w*", target), RegexOptions.IgnoreCase);
            MatchCollection match = regex.Matches(text);

            if (match.Count > 0)
            {
                Console.Write("Words: ");
                foreach (var word in match)
                {
                    Console.Write("\"{0}\", ", word);
                }
            }
            else
            {
                Console.WriteLine("No words were found!");
            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            string target = "test";
            string text = "Testing is important. We need to test everything.";
            PrintTargets(target, text);
        }
    }
}
